using System;
using System.Diagnostics;
using System.Collections.Generic;

namespace OpenRay
{
	//Immutable Class
	public class SmoothTriangleGeometry : TriangleGeometry
	{		
		public SmoothTriangleGeometry ( IList<Point> p, IList<Vector> n, IList<Material> m )
			: base( p, n, m )
		{
			Debug.Assert( p.Count == 3, "Incorrect number of vertices provided" );
			Debug.Assert( n.Count == 3, "Incorrect number of normals provided" );
			Debug.Assert( m.Count == 3, "Incorrect number of materials provided" );
		}
		
		public override Material Material (Point modelHit, InterpolationData interpolation)
		{
			return new CompositeMaterial(materials, interpolation);
		}
		
		public override Vector Normal (Point modelHit, InterpolationData interpolation)
		{
			return normals[0] * interpolation[0] + normals[1] * interpolation[1] + normals[2] * interpolation[2];
		}
	}
}

